﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using FlexiCache;
using System.Collections.Specialized;

namespace CLOComponentlibCSFixture.FlexiCache
{
    [TestClass()]
    public class CacheDataUtilityFixture : CacheDataUtility
    {
        [TestInitialize]
        public void Setup()
        {
        }

        [TestCleanup]
        public void TearDown()
        {
        }

        [Ignore()]
        [TestMethod]
        public void Test001_SerializeAndDeserialize()
        {
            byte[] data = null;
            byte[] dataOut = null;
            byte[] dataTmp = null;
            Random rnd = new Random(DateTime.Today.Millisecond);
            int iterationCount = 20000;
            System.Security.Cryptography.RandomNumberGenerator gen = System.Security.Cryptography.RandomNumberGenerator.Create();
            for (int ii = 0; ii < iterationCount; ii++)
            {
                data = new byte[rnd.Next(5000, 1000000)];//~5Kb- ~1Mb
                gen.GetBytes(data);

                dataTmp = base.Serialize(data);
                dataOut = (byte[])base.Deserialize(dataTmp);

                Assert.AreEqual(data, dataOut);
            }
        }

        [TestMethod]
        public void Test002_ComputeCacheStorageKey()
        {
            string key = CacheDataUtility.ComputeCacheStorageKey("8c64d859-0ea1-402a-8b00-57f48c6a5a3d");
            System.Diagnostics.Trace.WriteLine("The converted key: " + key);
        }
    }
}
